package com.bigdata.bookinfo.reduce;

import com.bigdata.bookinfo.pojo.Book;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class BookReduce extends Reducer<Text, Book, Text, Text> {

    @Override
    protected void reduce(Text key, Iterable<Book> values, Context context) throws IOException, InterruptedException {
        Book book = new Book();
        for (Book value : values) {
            book = value;
        }
        context.write(new Text(book.getTitle()), new Text(book.toString()));
    }
}
